Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated String.prototype.substr() #10243

Merged
merged 1 commit into from
Mar 18, 2022
Merged

Replace deprecated String.prototype.substr() #10243

merged 1 commit into from
Mar 18, 2022

Conversation

CommanderRoot
Copy link
Contributor

String.prototype.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated.
.substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.

@@ -39,7 +39,7 @@ export function isArray(value) {
return true;
}
const type = Object.prototype.toString.call(value);
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
if (type.startsWith('[object') && type.endsWith('Array]')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (type.startsWith('[object') && type.endsWith('Array]')) {
if (type.substring(0, 7) === '[Object]' && type.substring(type.length-6) === 'Array]') {

Bit better performance as starts and endWith

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I removed the startsWith and endsWith usage

@LeeLenaleee LeeLenaleee added this to the Version 3.8.0 milestone Mar 18, 2022
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with similar functions which aren't deprecated.
Signed-off-by: Tobias Speicher <[email protected]>
@stockiNail
Copy link
Contributor

I have removed my post, sorry. It was in the wrong project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants